from itertools import combinations

magic_square3x3 = list()
comb_list = list()
comb2 = list(combinations([0, 1, 2, 3, 4, 5, 6, 7], 3))
t = 0
for i in range(len(comb2)):
    m = comb_list[comb2[i][0]] + comb_list[comb2[i][1]] + comb_list[comb2[i][2]]
    test_list = list(set(m))
    if len(test_list) == 9:
        for r in range(len(all_perm)):
            m = list()
            for j in range(9):
                m.append(
                    comb_list[comb2[i][all_perm[r][int(j / 3)]]][all_perm[r][3 + j]]
                )
            t += 1

            # print(m,comb_list[comb2[i][0]]+comb_list[comb2[i][1]]+comb_list[comb2[i][2]],row_perm[r],col_perm[c])
            if is_magic3x3(m):
                magic_square3x3.append(m)
            # print(m,test_list)
print(t, len(magic_square3x3))
